package sys.interaction;

import sys.event.SportingEvent;
import sys.person.AbstractPerson;
import sys.person.Manager;
import sys.ui.ManagerMenu;
import sys.util.EventUtil;

import java.util.Scanner;

import static sys.interaction.IteracMain.interMain;

public class IteracManager {

    static int select;
    public static void interManager() {

        Scanner input = new Scanner(System.in);
        Manager manager = new Manager();

        while (true) {

            ManagerMenu.display();

            select = input.nextInt();
            switch (select) {
                case 1 : {
                    AbstractPerson.browseEvent();
                    break;
                }
                case 2 : {

                    String eventID;
                    String eventName;
                    String place;
                    String rule;

                    System.out.println("请分别输入项目编号，项目名称，举办地点，项目规则");

                    eventID = input.next();
                    eventName = input.next();
                    place = input.next();
                    rule = input.next();

                    manager.addEvent(new SportingEvent(eventID, eventName, place, rule));
                    System.out.println("添加成功！");
                    AbstractPerson.browseEvent();
                    break;
                }
                case 3 : {
                    String eventID;
                    String place;

                    AbstractPerson.browseEvent();

                    System.out.println("参照您要更改的项目，输入对应的项目编号以及目标地点");

                    eventID = input.next();
                    place = input.next();

                    manager.changePlace(eventID, place);
                    System.out.println("更改成功！");
                    System.out.println("更改后：");
                    EventUtil.showEnvent(eventID);

                    break;
                }
                case 4 : {

                    String eventID;
                    String rule;

                    AbstractPerson.browseEvent();

                    System.out.println("参照您要更改的项目，输入对应的项目编号以及目标规则");

                    eventID = input.next();
                    rule = input.next();

                    manager.changeRule(eventID, rule);
                    System.out.println("更改成功！");
                    System.out.println("更改后：");
                    EventUtil.showEnvent(eventID);

                    break;
                }
                case 0 : {
                    interMain();
                    break;
                }
                default: {
                    System.out.print("请重新输入： ");
                }
            }
        }
    }
}
